package com.nit.generate;

import com.nit.tools.loop.NitLoopTools;

/**
 * 手机号生成器
 *
 * @Auth: 逆天开源-逍遥哥哥
 * @link: 1715656022@qq.com
 * @Date: 2023-07-11
 */
public class NitPhoneGenerator {
    public static void main(String[] args) {
        NitLoopTools.loop(100, () -> {
            String phone = NitPhoneGenerator.generate();
            System.out.println("随机手机号码:" + phone + "<br>");
        });
    }

    private final static String[] PREFIX = {"130", "131", "132", "133", "134", "135", "136", "137",
            "138", "139", "150", "151", "152", "153", "154", "155", "156", "157", "158",
            "159", "180", "181", "182", "183", "184", "185", "186", "187", "188", "189",
            "141", "145", "146", "147", "148", "149", "162", "165", "166", "167", "170",
            "171", "172", "173", "174", "175", "176", "177", "178", "191", "198", "199"};

    public static String generate() {
        // 使用StringBuilder来连接字符串
        StringBuilder sb = new StringBuilder();
        //添加号段
        sb.append(PREFIX[(int) (Math.random() * 52)]);
        NitLoopTools.loop(8, () -> sb.append((int) (Math.random() * 10)));
        return sb.toString();
    }


}